<?php
/**
 * Created by PhpStorm.
 * User: xiao
 * Date: 2017/6/30
 * Time: 下午1:51
 */

namespace app\domain;


use app\src\account\enmu\AccountEnmu;
use app\src\withdrawDeposit\action\WithdrawDepositAction;

class WithdrawDepositDomain extends BaseDomain
{

    /**
     * 提现申请
     */
    public function apply()
    {
        $this->checkVersion('102', '增加类型');

        $account_type = $this->_post('account_type', '', 'account_type is missing');
        $account_id = $this->_post('account_id', '', 'account_id is missing');
        $score = $this->_post('score', '', 'score is missing');
        $bank_card_name = $this->_post('bank_card_name', '', 'bank_card_name is missing');
        $bank_card_no = $this->_post('bank_card_no', '', 'bank_card_no is missing');
        $mobile = $this->_post('mobile', '', 'mobile is missing');
        $name = $this->_post('name', '', 'name is missing');

        $apply_info = [
            'bank_card_name' => $bank_card_name,
            'bank_card_no' => $bank_card_no,
            'mobile' => $mobile,
            'name' => $name
        ];

        $result = (new WithdrawDepositAction)->addApply($account_type, $account_id, $score, $apply_info);

        if($result['status']){
            $this->apiReturnSuc('申请成功，请等待客服处理');
        }else{
            $this->apiReturnErr($result['info']);
        }
    }

    /**
     * 提现申请列表
     */
    public function applyList()
    {
        $this->checkVersion('101', '增加类型');
        $account_type = $this->_post('account_type', '', 'account_type is missing');
        $account_id = $this->_post('account_id', '', 'account_id is missing');

        $result = (new WithdrawDepositAction)->queryApply($account_type, $account_id, $this->getPageParams());

        if($result['status']){
            $this->apiReturnSuc($result['info']);
        }else{
            $this->apiReturnErr($result['info']);
        }
    }
}